package create

import (
	"context"
	"math"
	"time"

	"go.mongodb.org/mongo-driver/bson/primitive"
	"go.mongodb.org/mongo-driver/mongo"
)

func Base(mongo *mongo.Database, ctx context.Context) {
	// 初始化一个包含常见类型的结构体，保存到mongo看看
	baseAdd1 := BaseAdd{
		Id:         math.MaxInt,
		Int32:      math.MaxInt32,
		Int64:      math.MaxInt64,
		Float32:    math.MaxFloat32,
		Float64:    math.MaxFloat64,
		Text:       "hello1",
		Boolean:    true,
		ByteList:   []byte{'a', 'b', 'c', 'd', 'e'},
		StringList: []string{"test1", "test2", "test3"},
		IntList:    []int32{1, 2, 54, 7, 9, 6, 23, 5, 4, 7, 2},
		Date:       time.Now(),
		Object:     Obj{Id: 1, Text: "你好"},
		ObjectID:   primitive.NewObjectID(),
	}
	baseAdd1.Add(mongo, ctx)
	baseAdd2 := BaseAdd{
		Id:         math.MaxInt - 1,
		Int32:      math.MaxInt32 - 1,
		Int64:      math.MaxInt64 - 1,
		Float32:    math.MaxFloat32 - 1,
		Float64:    math.MaxFloat64 - 1,
		Text:       "hello2",
		Boolean:    false,
		ByteList:   []byte{'c', 'd', 'e', 'f', 'g'},
		StringList: []string{"test3", "test4", "test5"},
		IntList:    []int32{7, 58, 456, 13, 61, 25, 0, 0, 53, 54, 6, 20, 3, 2, 1, 3},
		Date:       time.Now(),
		Object:     Obj{Id: 2, Text: "不太好"},
		ObjectID:   primitive.NewObjectID(),
	}
	AddMany(mongo, ctx, baseAdd1, baseAdd2)
}

func Advance(mongo *mongo.Database, ctx context.Context) {
	// AddField(mongo, ctx)
	AddChildField(mongo, ctx)
	// AddArrayChildField(mongo, ctx)
	AddArrayChildAllField(mongo, ctx)
	// AddFieldWithUpsert(mongo, ctx)
	// AddFieldWithReplaceWith(mongo, ctx)
	// AddFieldWithMergeObjects(mongo, ctx)
	// AddFieldWithIfNull(mongo, ctx)
	// AddFieldWithFind(mongo, ctx)

}

func Array(mongo *mongo.Database, ctx context.Context) {
	// AddArrayElement(mongo, ctx)
	// AddArrayElementWithEach(mongo, ctx)
	// AddArrayElementWithPush(mongo, ctx)
	// AddArrayElementWithPosition(mongo, ctx)
}
